package com.xuliugen.javamybatis.demo.service;

import com.xuliugen.javamybatis.demo.dto.UserDTO;
import com.xuliugen.javamybatis.demo.mapper.UserMapper;
import com.xuliugen.javamybatis.demo.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * Created by xuliugen on 2017/9/20.
 */
public class UserService {

    public UserDTO selectUserById(Integer userID) {
        SqlSession session = SqlSessionUtil.getSqlSession();
        UserMapper userMapper = session.getMapper(UserMapper.class);
        UserDTO userDTO = userMapper.selectByPrimaryKey(userID);
        return userDTO == null ? new UserDTO() : userDTO;
    }
}
